package com.jqk.shop_product.listener;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.jqk.shop_product.bean.Order;
import com.jqk.shop_product.bean.TblOrderEvent;
import com.jqk.shop_product.service.TblOrderEventService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author:jiangqikun
 * @Date:2022/3/3 11:15
 **/
@Slf4j
@Service
@RocketMQMessageListener(consumerGroup = "shop-product", topic = "order-topic")
public class MessageListener implements RocketMQListener<String>{

    @Autowired
    private TblOrderEventService tblOrderEventService;

    @Override
    public void onMessage(String message) {
        TblOrderEvent tblOrderEvent = JSONObject.parseObject(message,TblOrderEvent.class);
        tblOrderEvent.setOrderType("3");
        tblOrderEventService.save(tblOrderEvent);
    }

}